| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | // Third Party Libraries |
||
| 23 | function fileDrop(form) |
||
| 24 | { |
||
| 25 | // Initialize Drag and Drop |
||
| 26 | var drop = $('#dropzone-box').dropzone( |
||
|
|
|||
| 27 | { |
||
| 28 | url: form.attr('action'), |
||
| 29 | autoProcessQueue: false, |
||
| 30 | maxFilesize: maxUpload, |
||
| 31 | uploadMultiple: false, |
||
| 32 | parallelUploads: 1, |
||
| 33 | maxFiles: 1, |
||
| 34 | addRemoveLinks: true, |
||
| 35 | init: function() |
||
| 36 | { |
||
| 37 | var myDrop = this; |
||
| 38 | form.on('submit', function(e, formData) |
||
| 39 | { |
||
| 40 | e.preventDefault(); |
||
| 41 | myDrop.processQueue(); |
||
| 42 | $('#forProgressBar').show(); |
||
| 43 | $('.submit-button').attr('disabled', true); |
||
| 44 | }); |
||
| 45 | this.on('sending', function(file, xhr, formData) |
||
| 46 | { |
||
| 47 | var formArray = form.serializeArray(); |
||
| 48 | $.each(formArray, function() |
||
| 49 | { |
||
| 50 | formData.append(this.name, this.value); |
||
| 51 | }); |
||
| 52 | }); |
||
| 53 | this.on('totaluploadprogress', function(progress) |
||
| 54 | { |
||
| 55 | $("#progressBar").css("width", Math.round(progress)+"%"); |
||
| 56 | $("#progressStatus").text(Math.round(progress)+"%"); |
||
| 57 | console.log(progress); |
||
| 58 | }); |
||
| 59 | this.on('reset', function() |
||
| 60 | { |
||
| 61 | $('#form-errors').addClass('d-none'); |
||
| 62 | }); |
||
| 63 | this.on('success', function(files, response) |
||
| 64 | { |
||
| 65 | uploadComplete(response); |
||
| 66 | }); |
||
| 67 | this.on('error', function(file, response) |
||
| 68 | { |
||
| 69 | uploadFailed(response); |
||
| 70 | }); |
||
| 71 | } |
||
| 72 | }); |
||
| 73 | } |
||
| 74 | |||
| 163 |